#include "test.h"
#include <stdlib.h>

static Application testingApplication("Random Name");




Test::Test() : Node(50 * MILLISECONDS)
{
}

Test::~Test() {

}

StatusData* Test::work() {
	//Get the data
	status.posX = satelliteData.posX;
	status.posY = satelliteData.posY;
	status.posZ = satelliteData.posZ;
	status.temperature = satelliteData.temperature;



	//Wait (to simulate more working)
	waitUntil(NOW()+23 * MILLISECONDS);
	//Publish the data
	return &status;
}


DataGenerator::DataGenerator(): Thread("DataGenerator"){
}

void DataGenerator::run() {
	//Generate new data every second
	TIME_LOOP(NOW(), 1*SECONDS) {
		satelliteData.posX = ((double)rand()) / RAND_MAX * 300000.0L; //In km
		satelliteData.posY = ((double)rand()) / RAND_MAX * 300000.0L;
		satelliteData.posZ = ((double)rand()) / RAND_MAX * 300000.0L;
		satelliteData.temperature = ((double)rand()) / RAND_MAX * 70.0L - 20.0L; //In °C
	}
}
